home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / bbs / cddk9606.zip / HEADERS.ARJ / SCRIPTS.INT < prev    next >
Text File  |  1996-06-14  |  5KB  |  180 lines

  1.  
  2. { ───────────────────────────────────────────────────────────────────────── }
  3. {  SCRIPTS: Script Interpreter                                              }
  4. {  Copyright 1996 David Pinch ∙ All Rights Reserved Worldwide               }
  5. { ───────────────────────────────────────────────────────────────────────── }
  6.  
  7. UNIT Scripts;
  8.  
  9. {$B-} { . . . . . . . . . . . . . . . . . . . . Shortcut boolean evaluation }
  10. {$F+} { . . . . . . . . . . . . . . . . . . . .  Force far calls for safety }
  11. {$I-} { . . . . . . . . . . . . . . . . . . . Disable input/output checking }
  12. {$O+} { . . . . . . . . . . . . . . . . . . Allow this unit to be overlayed }
  13. {$Q-} { . . . . . . . . . . . . . .  Do not generate overflow-checking code }
  14. {$R-} { . . . . . . . . . . . . . . . . Do not generate range-checking code }
  15. {$S-} { . . . . . . . . . . . . . . . . Do not generate stack-checking code }
  16. {$X+} { . . . . . . . . . . . Extended syntax for pChars and function calls }
  17.  
  18. INTERFACE
  19.  
  20. USES
  21.   Objects;
  22.  
  23. CONST
  24.  
  25.   { Identifier types }
  26.  
  27.   _Unknown  = $00;     { . . . .  Unknown type or reserved identifier name }
  28.   _Function = $01;     { . . . . . . . . . . . Programmer-defined function }
  29.   _Label    = $02;     { . . . . . . . . . . . . . Reserved for future use }
  30.   _Variable = $03;     { . . . . . . . . . . . Programmer-defined variable }
  31.   _Status   = $04;     { . . . . . . . . . . . . Reserved for status lines }
  32.   _Menu     = $05;     { . . . . . . . . . . . . . . .  Reserved for menus }
  33.  
  34.  
  35. TYPE
  36.  
  37.   tID = OBJECT(tObject)
  38.  
  39.     NameStr : pChar;   { . . . . . . . . . . . . The name of the identifier }
  40.     NameCRC : LongInt; { . . . . . . . . . . . . The 32-bit CRC of its name }
  41.     Family  : Word;    { . . . The family of the identifier (i.e. variable) }
  42.  
  43.     CONSTRUCTOR Init(p:pChar; k:Word);
  44.     DESTRUCTOR  Done; VIRTUAL;
  45.     END;
  46.  
  47.   pID = ^tID;
  48.  
  49.   tParams = OBJECT(tCollection)
  50.     PROCEDURE FreeItem(Item:Pointer); VIRTUAL;
  51.     PROCEDURE InsertString(p:pChar); VIRTUAL;
  52.     END;
  53.  
  54.   pParams = ^tParams;
  55.  
  56.   tFunction = OBJECT(tID)
  57.     Handler : PROCEDURE(p:pParams);
  58.     Params  : Byte;
  59.     CONSTRUCTOR Init(p:pChar; HandlerPtr:Pointer; Count:Byte);
  60.     END;
  61.  
  62.   pFunction = ^tFunction;
  63.  
  64.   tVariable = OBJECT(tID)
  65.     Address  : Pointer;
  66.     ReadOnly : Boolean;
  67.     CONSTRUCTOR Init(p:pChar; Addr:Pointer);
  68.     PROCEDURE Assign(p:pChar); VIRTUAL;
  69.     FUNCTION  Obtain:STRING; VIRTUAL;
  70.     END;
  71.  
  72.   pVariable = ^tVariable;
  73.  
  74.  
  75. CONST
  76.   IDs       : pCollection = NIL;
  77.   ScriptDir : pChar       = NIL;
  78.  
  79.  
  80. {#Start}
  81.  
  82. PROCEDURE DeleteID(p:pChar);
  83.   {
  84.   PURPOSE  : Deletes the identifier.
  85.  
  86.   NOTES    : The name of the identifier is not case-sensitive.
  87.   }
  88.  
  89.  
  90. FUNCTION Execute(Source:pChar):Word;
  91.   {
  92.   PURPOSE  : Interpreters the string of commands.
  93.  
  94.   SEE ALSO : Script
  95.   }
  96.  
  97.  
  98. FUNCTION Let(Variable,Equal:pChar):Boolean;
  99.   {
  100.   PURPOSE  : Assigns a value to the specified variable.
  101.  
  102.   RETURNS  : TRUE if the operation was successful, FALSE if not.  The
  103.              operation will fail if the specified variable is read-only
  104.              or does not exist.
  105.   }
  106.  
  107.  
  108. PROCEDURE MakeReadOnly(Variable:pChar);
  109.   {
  110.   PURPOSE  : Makes a script variable read-only.  A read-only variable cannot
  111.              be modified by the sysop.
  112.  
  113.   NOTES    : This procedure merely flags the variable as read-only.  It
  114.              offers no protection against physical modification of the
  115.              EXE using a hex editor or DEBUG.
  116.  
  117.   EXAMPLE  : PROCEDURE Protect_Software;
  118.                BEGIN
  119.                MakeReadOnly('Author');
  120.                MakeReadOnly('Copyright');
  121.                MakeReadOnly('Version');
  122.                END;
  123.   }
  124.  
  125.  
  126. PROCEDURE Parse(p:pChar; VAR Index,Length,Next:Word);
  127.   {
  128.   PURPOSE  : Parses a token in a string.
  129.  
  130.   PARAMS   : p        The string to parse.
  131.              Index    The starting position of the parser.  Upon return
  132.                       this variable contains the starting position of
  133.                       the next token.
  134.              Length   The length of the token.
  135.              Next     The suggested starting position of the next Parse call.
  136.   }
  137.  
  138.  
  139. PROCEDURE RegisterFunction(Name:pChar; Addr:Pointer; Count:Byte);
  140.   {
  141.   PURPOSE  : Registers a function with the script interpreter.
  142.  
  143.   PARAMS   : Name     The name of the function (not case-sensitive).
  144.              Addr     The address of the function handler.
  145.              Count    The number of parameters to send to the handler.
  146.  
  147.   NOTES    : A function handler is declared as follows:
  148.  
  149.              PROCEDURE <NAME>(<POINTER>:pParams);
  150.  
  151.              Where <NAME> is the name of the handler, and <POINTER>
  152.              is the name of a tParams pointer.  The handler must use
  153.              any other parameters; this will cause memory stack problems.
  154.   }
  155.  
  156.  
  157. FUNCTION Script(p:pChar):Word;
  158.   {
  159.   PURPOSE  : Executes a script file.
  160.  
  161.   NOTES    : The ScriptDir string is used instead of any specified path,
  162.              if ScriptDir is not NIL.
  163.  
  164.   SEE ALSO : Execute
  165.   }
  166.  
  167.  
  168. FUNCTION SearchFor(p:pChar):pID;
  169.   {
  170.   PURPOSE  : Scans the list of identifiers stored in IDs and returns a
  171.              pointer if the specified name exists.
  172.   }
  173.  
  174.  
  175. IMPLEMENTATION
  176.  
  177. { The source code is available upon registration. }
  178.  
  179. END.
  180.